package com.liuyucheng.java8.lambda_stream;

import com.liuyucheng.java8.lambda_stream.entity.Product;

import java.util.ArrayList;
import java.util.List;

/**
 * @author LiuYuCheng
 * @date 2021年09月17日 00:08
 */
public class LambdaTest {

    public static String join(String prefix,String suffix){
        return prefix.concat(suffix);
    }

    public static void main(String[] args) {
//        System.out.println(join("123","456"));
//        Comparator<String> comparator = (o1, o2) -> o1.compareTo(o2);
//        Thread thread = new Thread(() -> System.out.println("dddd"));


        List<Product> list = new ArrayList<>();
        list.add(new Product().setColor("red").setPrice(10000));
        list.add(new Product().setColor("blue").setPrice(10000));
        list.add(new Product().setColor("yellow").setPrice(900));

        //根据属性值进行过滤,filter
        list.stream()
                .filter((product -> product.getPrice()<5000))
                .forEach(System.out::println);

        //遍历
        list.stream()
                .map(Product::getColor)
                .forEach(System.out::println);
    }


}
